<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .rating {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            font-size: 48px;
            /* 查阅下面这个CSS属性 */
            unicode-bidi: bidi-override;
            direction: rtl;
        }

        .rating>span {
            position: relative;
        }

        /* 在CSS中，无法选择先前的子元素。然而，有一种方式可以选择后续的元素，即通过同胞选择器。 */
        .rating>span:hover::before,
        .rating>span:hover~span::before {
            content: "\2605";
            /* 用绝对定位，直接覆盖 */
            position: absolute;
            color: gold;
        }
    </style>
</head>

<body>
    <!-- 原文链接：https://blog.csdn.net/huopo125/article/details/38466961 -->
    <div class="rating">
        <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span>
    </div>
</body>

</html>